package org.mendoza.salud.hvt.server.erraiinterfaces;

import org.jboss.errai.bus.server.annotations.Service;
import org.mendoza.salud.hvt.client.shared.model.AbstractEntity;
import org.mendoza.salud.hvt.client.shared.model.services.PersistenceServiceRemote;
import org.mendoza.salud.hvt.server.global.PersistenceServiceBean;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import java.util.List;

/**
 * Created by administrador on 06/10/14.
 */
@RequestScoped
@Service
public class PersistenceService implements PersistenceServiceRemote {
    @Inject
    PersistenceServiceBean persistenceServiceBean;

    public <T extends AbstractEntity> T persist(T entidad) {
        return persistenceServiceBean.persist(entidad);
    }

    @Override
    public <T extends AbstractEntity> T merge(T entidad) {
        return persistenceServiceBean.merge(entidad);
    }

    @Override
    public <T extends AbstractEntity> List<T> findAll(String nombreEntidad) {
        return persistenceServiceBean.findAll(nombreEntidad + ".all");
    }

}
